package com.teamclub.domain.system;


import io.ebean.Ebean;
import io.ebean.Finder;
import io.ebean.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Transient;
import javax.persistence.Version;
import java.util.Date;

/**
 * Created by ilkkzm on 17-8-16.
 */
@Entity
@Data
@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
public class AppDomainInstance extends Model {
    @Id
    private Integer id;

    private String name;  // instance 名称

    private String appDomain; // instance 所属域

    private String organNo; // 组织机构号

    private String funcTreeRef;

    private Boolean isAdmin;

    private Date validateDate;

    @Version
    private Integer updateVersion;

    @Transient
    private String appName;

    public static Finder<Integer, AppDomainInstance> finder = new Finder<>(AppDomainInstance.class);

    public String getAppName() {
        AppDomain xx = Ebean.find(AppDomain.class).where().eq("appKey", appDomain).findOne();
        return xx == null ? "" : xx.getAppName();
    }

}
